Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

fix: don't restart application when lazy loaded code is changed in angular app with uglify option #957

Merged
merged 1 commit into from
Jul 2, 2019

Conversation

Fatme
Copy link
Contributor

@Fatme Fatme commented Jun 30, 2019

Currently there is a logic that gets all runtime files and entry point files from webpack compilation. These files are needed to CLI in order to decides if the application should be restarted or refreshed on device(when there is at least one file that is not hot update file, CLI restarts the application). However, this logic doesn't work for lazy loaded modules in angular application as they are reported neither entry point files nor runtime files. Lazy loaded modules are directly injected into webpack compilation using the hooks of ContextModuleFactory - https://github.com/angular/ngtools-webpack-builds/blob/39ccb0b487e92a7ac4330ff9db821337b7aa5c45/src/angular_compiler_plugin.js#L516. This PR fixes the behavior with lazy loaded files as it gets all chunks produced from webpack compilation and omits hot-update.js files from them. Chunk files are: runtime.js, tns_modules/inspector-modules.js, bundle.js, vendor.js and all lazy loaded modules in other words runtime files + entry point files + splitted files from compilation + lazy loaded files for angular. When a files is changed in hmr mode, .hot-update.js file is included into chunk files. This way we don't need to separate the files to entry point, runtime, lazy loaded and others. We just need to omit .hot-update.js file from chunk files from webpack compilation and pass them to the CLI.

PR Checklist

What is the current behavior?

What is the new behavior?

Fixes/Implements/Closes #[Issue Number].

…gular app with uglify option

Currently there is a logic that gets all runtime files and entry point files from webpack compilation. These files are needed to CLI in order to decides if the application should be restarted or refreshed on device(when there is at least one file that is not hot update file, CLI restarts the application). However, this logic doesn't work for lazy loaded modules in angular application as they are reported neither entry point files nor runtime files. Lazy loaded modules are directly injected into webpack compilation using the hooks of ContextModuleFactory - https://github.com/angular/ngtools-webpack-builds/blob/39ccb0b487e92a7ac4330ff9db821337b7aa5c45/src/angular_compiler_plugin.js#L516.  This PR fixes the behavior with lazy loaded files as it gets all chunks produced from webpack compilation and omits hot-update.js files from them. Chunk files are all files except hot update files. Chunk files are: `runtime.js`, `tns_modules/inspector-modules.js`, `bundle.js`, `vendor.js` and all lazy loaded modules. When a files is changed in hmr mode, <hash>.hot-update.js file is included into chunk files. This way we don't need to separate the files to entry point, runtime, lazy loaded and others. We just need to omit <hash>.hot-update.js file from chunk files from webpack compilation.
@cla-bot cla-bot bot added the cla: yes label Jun 30, 2019
@dtopuzov
Copy link
Contributor

dtopuzov commented Jul 2, 2019

test

@Fatme
Copy link
Contributor Author

Fatme commented Jul 2, 2019

test package_version#rc

1 similar comment
@Fatme
Copy link
Contributor Author

Fatme commented Jul 2, 2019

test package_version#rc

@Fatme Fatme merged commit b00fcdd into release Jul 2, 2019
@Fatme Fatme deleted the fatme/fix-ng-uglify branch July 2, 2019 13:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants